package com.cyh;

import com.cyh.core.framework.common.constant.FileConstant;
import com.cyh.core.framework.common.utils.ApplicationContextUtil;
import com.cyh.core.framework.common.utils.FileUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.util.Locale;


@EnableTransactionManagement
@EnableScheduling
@EnableJpaRepositories
@SpringBootApplication
public class WebApplication {

    public static void main(String[] args) {

        //指定时区，防止Linux系统时区不一致导致Jackson解析错误
        Locale.setDefault(Locale.SIMPLIFIED_CHINESE);
        SpringApplication app = new SpringApplication(WebApplication.class);
        //设置上下文对象
        ApplicationContext applicationContext =app.run(args);
        Environment env = applicationContext.getEnvironment();
        System.out.println("\n----------------------------------------------------------");
        System.out.println("    Application '"+env.getProperty("spring.application.name")+ "' is running! Access URLs:");
        System.out.println("    Local:       http://localhost:"+env.getProperty("server.port"));
        String FilePath=FileUtil.getRealPath(FileConstant.FILE_PATH);
        System.out.println("    FilePath:    "+ FilePath);
        System.out.println("\n----------------------------------------------------------");
        new ApplicationContextUtil().setApplicationContext(applicationContext);
    }

}
